package edu.sctu.practice.class02.hujie.cgs.assign03.One;


/**
 * Created by hj on 2015/10/22.
 */
public class Rectangle extends GeometricObject {
    //子类 矩形
    protected double width;
    protected double height;

    //Default constructor
    public Rectangle() {
        this(1.0, 1.0, "white", 1.0);
    }

    // Construct a rectangle with specified width and height
    //和下面的有啥用？？
    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    // Construct a rectangle with specified width, height, weight, and color
    //specified被指定的
    public Rectangle(double width, double height, String color, double weight) {
        super(color, weight);
        this.width = width;
        this.height = height;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }
//怎么没有调用？？
    public void setHeight(double height) {
        this.height = height;
    }

    // Implement the findArea method in GeometricObject
    public double findArea() {
        return width * height;
    }

    // Implement the findPerimeter method in GeometricObject
    public double findPerimeter() {
        return 2 * (width + height);
    }

    // Override the equals() method defined in the Object class
    public boolean equals(Rectangle rectangle) {
        return (width == rectangle.getWidth()) &&
                (height == rectangle.getHeight());
    }

    // Override the toString() method defined in the Object class
    public String toString() {
        return "[Rectangle] width=" + width + "and height=" + height;
    }

}
